package common.fengkai.filepost.service.impl;

import common.fengkai.filepost.service.AsyncTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.Random;

@Service
@Slf4j
public class AsycnTaskImpl implements AsyncTask {
    @Async("taskConfigA")
    @Override
    public void getAsync1 () throws InterruptedException {
        while (true){
            Thread.sleep(500);
            log.info("\"异步方法1\""+System.currentTimeMillis());
            int round = (int) Math.round(Math.random() * (20 - 10 + 1) + 10);
            if (round>=18){
                break;
            }
        }
        log.info("\"异步方法1执行结束\"");
    }

    @Async("taskConfigA")
    @Override
    public void getAsync2 () {
        System.out.println("异步方法2");
        log.debug("\"异步方法2\"");
    }


}
